package com.tide.crm.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.tide.crm.model.CustomerEvent;

@Mapper
public interface CustomerEventDao {

    @Select("select * from customer_event t where t.id = #{id}")
    CustomerEvent getById(Long id);

    @Delete("delete from customer_event where id = #{id}")
    int delete(Long id);

    int update(CustomerEvent customerEvent);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into customer_event(event, event_date, creater, create_date, modifyer, modify_date, type, contact_id) values(#{event}, #{eventDate}, #{creater}, #{createDate}, #{modifyer}, #{modifyDate}, #{type}, #{contactId})")
    int save(CustomerEvent customerEvent);
    
    int count(@Param("params") Map<String, Object> params);

    List<CustomerEvent> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    List<CustomerEvent> findListByHolderId(Long holderId);

    void deleteEventByContactId(Long holderId);
}
